class Solution14 {
    public String longestCommonPrefix(String[] strs) {
        if(strs == null || strs.length == 0) return "" ; 
        if(strs.length == 1) return strs[0] ; 
        int ret = 300 ; 
        char[] arr = strs[0].toCharArray() ;
        for(int i=1 ; i < strs.length ; i ++){
            int j = 0 ; 
            int count = 0 ; 
            char[] arr2 = strs[i].toCharArray() ;
            while(j <  arr.length  && j < arr2.length){
                 if(arr[j] == arr2[j]){
                    j ++ ;
                    count++ ;
                 }else{
                    break ;
                 }
            }
            if(count == 0){
                return "" ; 
            }else{
                ret = count<ret?count:ret ;
            }
        }
        if(ret == 300){
            return "" ;
        }else{
            return strs[0].substring(0,ret) ; 
        }
    }
}